package org.vectrics.recruiter.struts.tag;

import org.vectrics.DataException;
import org.vectrics.SystemException;
import org.vectrics.provider.CoreServiceLocator;
import org.vectrics.user.Person;
import org.apache.log4j.Category;
import org.vectrics.common.html.Table;
import org.vectrics.common.html.Row;
import org.vectrics.common.html.Cell;
import org.vectrics.common.view.FieldTable;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.ServletRequest;




public class HiddenUserSummaryTag extends RecruitUserSummaryTag {
	public static final long serialVersionUID = 73228793;
    private static Category log = Category.getInstance(HiddenUserSummaryTag.class);
    private Person user = null;
    //private RemoteUserProvider userManager = new RemoteUserProvider();


	public String makeStartTag() {
        log.debug("doRender() called");
		ServletRequest servletRequest = super.pageContext.getRequest();
		HttpServletRequest request = (HttpServletRequest)servletRequest;
        
        
        Table mainTable = new Table();
        Row mainRow = mainTable.addRow();
        Cell mainCell = mainRow.addCell();
    	try {    
        	user = findPerson(request);
    	}
    	catch (DataException de) {
    		log.error("DataException finding user", de);
    		throw new SystemException("DataException finding user", de); 
    	}
        FieldTable fieldTable = new FieldTable();
        fieldTable.setCellPadding(2);
        fieldTable.setWidth(500);
        fieldTable.setValueCellWidth("350");
        
        fieldTable.showField(this.getPhrase("prompt.user.name"), user.getUser().getUserName());
        fieldTable.showField(this.getPhrase("prompt.person.full.name"), user.getName());

        makeContactTable(fieldTable, user.getContactInfo());
        
		return(mainTable.toString());
    }
    
    

    
    protected Person findPerson(HttpServletRequest request) throws DataException {
        log.debug("findUserProfile() called");
        
        String userId = request.getParameter("user");
        Person user = CoreServiceLocator.getPersonService().findPersonById(new Long(userId));
        return(user);
    }


}